import { createBrowserRouter } from 'react-router-dom'
import { getLangByUrl } from '@/util'

import NotFound from '@/components/404/404'
import Init from '@/init/init'
import Index from '@/pages/index/index'
import Futures from '@/futures/futures'
import Engineering from '@/pages/engineering/engineering'

export const router = createBrowserRouter(
  [
    {
      path: '',
      auth: false,
      element: <Init />,
      children: [
        { path: '/', element: <Index /> },
        { path: '/futures/:InstrumentID?', element: <Futures /> },
      ],
    },
    {
      path: 'engineering',
      auth: false,
      element: <Engineering />,
    },
    {
      path: '*',
      auth: false,
      element: <NotFound />,
    },
  ],
  {
    basename: '/' + getLangByUrl(),
  },
)

// if (import.meta.hot) {
//   import.meta.hot.dispose(() => router.dispose());
// }
